package com.owg.jigsaw.hierarchy;

import com.owg.jigsaw.contour.Contour;

public abstract class TypeNodeBase implements TypeNode
{
	protected Contour contour;
	
	TypeNodeBase()
	{
		
	}
	@Override
	public boolean isParentOf(TypeNode n)
	{
		return n != this && n != null && n.isChildOf(this);
	}
	@Override
	public String toString()
	{
		return getClass().getSimpleName()+"("+getKey()+")";
	}
	@Override
	public void setContour(Contour c)
	{
		this.contour = c;
	}
	@Override
	public Contour getContour()
	{
		if(contour == null)
		{
			throw new IllegalStateException(this+" has no contour! The type must be added to a type hierarchy before being used in the application.");
		}
		return contour;
	}
	@Override
	public boolean hasContour()
	{
		return contour != null;
	}
}
